<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>修改资源</title>
</head>
<link type="text/css" rel="stylesheet" th:href="@{~/bootstrap-3.3.7/css/bootstrap.css}"/>
<script type="text/javascript" th:src="@{~/bootstrap-3.3.7/js/jquery.js}"></script>
<script type="text/javascript" th:src="@{~/bootstrap-3.3.7/js/bootstrap.js}"></script>

<body>

<h3 th:align="center">修改资源</h3>
<script>
    function xiugai(id) {
        var description = $("[name='description']").val();
        var status = $("[name='status']:checked").val();
        $.post(
            "/resource/updateResource",
            {
                id: id,
                description: description,
                status : status
            },
            function (data) {
                if (data == 1) {
                    alert("成功");
                    location.href = "/resource/listResource";
                } else {
                    alert("失败")
                }
            }
        );
    }
</script>
<form>
    <h3 th:align="center">修改资源</h3>
    <div class="row">
        <div class="form-group">
            <label for="inputEmail3" class="col-sm-2 control-label">资源名称</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" id="inputEmail3" th:value="${resource.name}" placeholder="Email"
                       disabled="disabled">
            </div>
        </div>
    </div>
    <div class="row">
        <div class="form-group">
            <label for="inputPassword3" class="col-sm-2 control-label">URL</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" id="inputPassword3" th:value="${resource.url}"
                       placeholder="Password" disabled="disabled">
            </div>
        </div>
    </div>
    <div class="row">
        <div class="form-group">
            <label class="col-sm-2 control-label">状态</label>
            <div class="col-sm-10">
                <input type="radio" th:name="status" th:value="0" th:checked="${resource.status}==0">启用
                <input type="radio" th:name="status" th:value="1" th:checked="${resource.status}==1">禁用
            </div>
        </div>
    </div>
    <div class="row">
        <div class="form-group">
            <label for="inputPassword4" class="col-sm-2 control-label">介绍</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" th:name="description" th:value="${resource.description}"
                       id="inputPassword4" placeholder="Password">
            </div>
        </div>
    </div>
    <div class="row">
        <div class="form-group">
            <label for="inputPassword5" class="col-sm-2 control-label">创建时间</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" id="inputPassword5"
                       th:value="${#dates.format(resource.createTime,'yyyy-MM-dd HH:mm:ss')}" placeholder="Password"
                       disabled="disabled">
            </div>
        </div>
    </div>

    <div class="row">
        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
                <a href="javascript:void(0)" class="btn btn-success btn-primary btn-xs"
                   th:onclick="'javascript:xiugai(\''+${resource.id}+'\')'">修改资源</a>
            </div>
        </div>
    </div>
</form>
</body>
</html>